package com.yuanfeng.job.service.impl;


import com.alibaba.fastjson.JSON;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.commoms.vo.job.AcquiescenceVO;
import com.yuanfeng.job.feign.OrderServiceClient;
import com.yuanfeng.job.feign.UserServiceClient;
import com.yuanfeng.job.mapper.JobOrderBaseMapper;
import com.yuanfeng.job.mapper.UpdateRecordStatusMapper;
import com.yuanfeng.job.service.UpdateRecordStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UpdateRecordStatusServiceImpl implements UpdateRecordStatusService {


	@Autowired
	private OrderServiceClient orderServiceClient;

	@Autowired
	private UserServiceClient userServiceClient;

	@Autowired
	private JobOrderBaseMapper jobOrderBaseMapper;

	@Autowired
	private UpdateRecordStatusMapper updateReceiverdRecordMapper;

	@Override
	public Integer updateReceiverdRecord(String paymentNumber) {

		return updateReceiverdRecordMapper.updateReceiverdRecord(paymentNumber);
	}

	@Override
	public Integer updateTimeoutRecord(String orderId) {
		return updateReceiverdRecordMapper.updateTimeoutRecord(orderId);
	}

	@Override
	public Integer updateTimeoutTrade(String orderId) {
		return updateReceiverdRecordMapper.updateTimeoutTrade(orderId);
	}

	@Override
	public Integer updateReceiverdTrade(String orderId) {
		return updateReceiverdRecordMapper.updateReceiverdTrade(orderId);
	}

	@Override
	public List<AcquiescenceVO> queryNotEvaluatedOrder() {
		ResponseResult result=orderServiceClient.queryNotEvaluatedOrder();
		List<AcquiescenceVO> voList = JSON.parseArray(JSON.toJSONString(result.getData()), AcquiescenceVO.class);
		return voList;
	}

	@Override
	public AcquiescenceVO queryUserInfo(String userId) {
		return userServiceClient.queryUserInfoByjob(userId);
	}

	@Override
	public List<AcquiescenceVO> queryGoodsInfo(String orderId) {
		return orderServiceClient.queryGoodsInfoByjob(orderId);
	}

	@Override
	public Integer insertEvaluated(AcquiescenceVO param) {
		return orderServiceClient.insertEvaluatedByJob(param).getCode();
	}

	@Override
	public Integer updateOrderEvaluated(String orderId) {
		return jobOrderBaseMapper.updateOrderEvaluated(orderId);
	}



	@Override
	public String queryShouHuoshijian(String orderId) {
		return jobOrderBaseMapper.queryorderFinishedTime(orderId);
	}


}
